const fs = require('fs');

//调用方法 读取文件
// fs.readFile('./resource/1.html', (err, data) => {
//     if(err) throw err;
//     console.log(data.toString());
// });

//Promise 包裹
let p = new Promise((resolve, reject) => {
    fs.readFile('./resource/1.html', (err, data) => {
        if(err){
            reject(err);
        }else{
            resolve(data.toString());
        }
    });
});

p.then(
    value => console.log(value)
    ,
    reason => console.log(reason.code)
)
